import Main from '../components/main.vue'
// const Main = r => require.ensure([], () => r(require('../components/main.vue')))

// import User from '../page/user/user.vue'
const User = resolve => { // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point // （代码分块）
  require.ensure(['../page/user/user.vue'], () => { resolve(require('../page/user/user.vue')) }, 'user') }

const userDetail = resolve => { require.ensure(['../page/user/userDetail.vue'], () => { resolve(require('../page/user/userDetail.vue')) }, 'userDetail') }

import page404 from '../page/page404.vue'

const routes = [{
    path: '/',
    redirect: '/user/vip',
    component: Main,
    children: [
      {
        path:'/user',
        redirect:'/user/vip'
      },
      {
        path: '/user/:type',
        component: User,
        name: 'user'
      },
      {
        path: '/msg-reply',
        name: 'msg-reply'
      }
    ]
  },
  {
    path: '/user-detail/:type',
    name: 'user-detail',
    component: userDetail
  },
  {
    path: '*',
    // redirect: '/404'
    component: page404
  }
  // {
  //   path: '/404',
  //   name: 'page404'
  // }
]
// scrollBehavior (to, from, savedPosition) {
//   if (savedPosition) {
//     return savedPosition
//   } else {
//     return { x: 0, y: 0 }
//   }
// }

export default routes
